package com.hebeiboruan.config;

import com.hebeiboruan.common.HttpMessage;
import com.hebeiboruan.common.exception.CommonException;
import com.hebeiboruan.common.exception.system.power.PowerException;
import com.hebeiboruan.common.exception.system.role.RoleException;
import com.hebeiboruan.common.exception.system.user.UserException;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 刘焕林
 * @date 2023/11/07
 */
@Component
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = {CommonException.class, RoleException.class, PowerException.class, UserException.class})
    public HttpMessage msgExceptionHandler(CommonException e){
        return new HttpMessage(e.getErrorCode(),e.getMessage());
    }

}
